import { createRouter, createWebHistory } from "vue-router";

import MainP from '../views/MainP.vue'

// 动态加载组件
const HomePage = () => import("../views/mainP/Home.vue");
const CategoryPage = () => import("../views/mainP/Category.vue");
const CartPage = () => import("../views/mainP/Cart.vue");
const ProfilePage = () => import("../views/mainP/Profile.vue");
const ProductPage = () => import("../views/Product.vue");
const Address= () => import("../views/address/Address.vue")
const Login = () => import("../views/LoginPage.vue")

const routes = [
  {
    path: "/",
    redirect: "/m/home",
    children: [
      {path: "product/:id",name: "Product",component: ProductPage,},
    ],
  },
  {
    path:'/m',name:'Main',component:MainP,children:[
      {path: "home",name: "Home",component: HomePage,},
      {path: "category",name: "Category",component: CategoryPage,},
      {path: "cart",name: "Cart",component: CartPage,},
      {path: "profile",name: "Profile",component: ProfilePage,},
    ]
  },
  { path: "/address",
    name: "Address",
    component: Address,
  },
  {
    path:'/myorder',name:'MyOrder',component:()=>import('../views/profileP/MyOrder.vue')
  },
	{
		name: "login",
		path: "/login",
		component: Login
	}
	
];

const router = createRouter({
	history: createWebHistory(import.meta.env.BASE_URL),
	routes,
});

export default router;
